package com.bw.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.util.SortedMap;

@Component
@Aspect
public class MyAop {

    @Around("execution(* com.bw.controller.*.*(..))")
    public Object aop(ProceedingJoinPoint joinPoint) throws Throwable {

        long l = System.currentTimeMillis();
        Object proceed = joinPoint.proceed();
        long l2 = System.currentTimeMillis();
        //{方法名称}，执行时间{时间}毫秒
        String name = joinPoint.getSignature().getName();
        System.out.println(name + ",执行时间" + (l2 - l) + "毫秒");
        return proceed;
    }
}
